package com.example.myapplication2030606131wjw;

import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;

import androidx.appcompat.app.AppCompatActivity;
import androidx.constraintlayout.widget.ConstraintLayout;

public class MainActivity extends AppCompatActivity {

    private ImageView lightOn;
    private Button trnOn;
    private Button trnOff;
    private ConstraintLayout trnOnAngOff;
    private ImageView imageView2;
    private Button button;

    private boolean fan_on_and_off = false;
    private Button button2;
    private  int[]lines;
    private int linesID=0;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        initView();

        //设置开灯按钮的监听器，点击on更换图片
//        trnOn.setOnClickListener(new View.OnClickListener() {
//            @Override
//            public void onClick(View view) {
//                lightOn.setImageResource(R.drawable.light_on);
//            }
//        });
//        //设置开灯按钮的监听器，点击on更换图片
//        trnOff.setOnClickListener(new View.OnClickListener() {
//            @Override
//            public void onClick(View view) {
//                lightOn.setImageResource(R.drawable.light_off);
//            }
//        });
//
//        //单个按钮控制单开关
//        button.setOnClickListener(new View.OnClickListener() {
//            @Override
//            public void onClick(View v) {
//                if (fan_on_and_off) {
//                    imageView2.setImageResource(R.drawable.fan_on);
//                    fan_on_and_off = false;
//                } else {
//                    imageView2.setImageResource(R.drawable.fan_off);
//                    fan_on_and_off = true;
//                }
//            }
//        });

        lines=new int[6];
        lines[0]=R.drawable.lion_1;
        lines[1]=R.drawable.lion_2;
        lines[2]=R.drawable.lion_3;
        lines[3]=R.drawable.lion_4;
        lines[4]=R.drawable.lion_5;
        lines[5]=R.drawable.lion_6;

        lightOn.setImageResource(lines[linesID]);
        button2.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                lightOn.setImageResource(lines[linesID+1]);
                linesID=+1;
            }
        });



    }

    private void initView() {
        lightOn = (ImageView) findViewById(R.id.light_on);
        trnOn = (Button) findViewById(R.id.trn_on);
        trnOff = (Button) findViewById(R.id.trn_off);
        trnOnAngOff = (ConstraintLayout) findViewById(R.id.trn_on_ang_off);
        imageView2 = (ImageView) findViewById(R.id.imageView2);
        button = (Button) findViewById(R.id.button);
        button2 = (Button) findViewById(R.id.button2);
    }
}